<?php


namespace App\Services;


use EasyWeChat\Factory;

class WeChatMiniAppService
{

    protected $app;

    public function __construct()
    {
        $config = [
            'app_id' => config('account.wxapp.app_id'),
            'secret' => config('account.wxapp.secret'),
            'aes_key' => config('account.wxapp.aes_key'),
            'token' => config('account.wxapp.token'),
            
            // 下面为可选项
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
        ];

        $this->app = Factory::miniProgram($config);
    }

    /**
     * @return \EasyWeChat\MiniProgram\Application
     */
    public function getApp(): \EasyWeChat\MiniProgram\Application
    {
        return $this->app;
    }
}
